package com.alan.mapper;

import com.alan.entity.Account;
import com.alan.entity.LoginUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Select("select * from db_account where username=#{text} or email=#{text}")
    Account findAccountByUsernameOrEmail(String text);

    @Insert("insert into db_account (username,email,password) values (#{username},#{email},#{password})")
    int createAccount(String username,String email,String password);

    @Update("update db_account set password = #{password} where email = #{email}")
    int resetPasswordByEmail(String password, String email);

    @Select("select * from db_account where username = #{text} or email = #{text}")
    LoginUser findAccountUserByNameOrEmail(String text);
}
